import paramiko

class SFTPClientWrapper:
    def __init__(self, ssh_client):
        self.ssh_client = ssh_client
        self.sftp = None

    def connect(self):
        if not self.ssh_client.client:
            self.ssh_client.connect()
        self.sftp = self.ssh_client.client.open_sftp()

    def listdir(self, path):
        if not self.sftp:
            raise Exception('SFTP not connected')
        return self.sftp.listdir(path)

    def upload(self, local_path, remote_path):
        if not self.sftp:
            raise Exception('SFTP not connected')
        self.sftp.put(local_path, remote_path)

    def download(self, remote_path, local_path):
        if not self.sftp:
            raise Exception('SFTP not connected')
        self.sftp.get(remote_path, local_path)

    def close(self):
        if self.sftp:
            self.sftp.close()
            self.sftp = None